export function generateTypes(obj: any, typeName: string): string {
    const startLabel = `export type ${typeName} = {`
    const endLabel = '}'
    let content = ''
    for (const key1 in obj) {
        if (Object.prototype.hasOwnProperty.call(obj, key1)) {
            const value = obj[key1]
            const prefix = key1
            if (typeof value === 'object') {
                for (const key2 in value) {
                    if (Object.prototype.hasOwnProperty.call(value, key2)) {
                        content = content + `'${prefix}.${key2}':string`
                    }
                }
            }
        }
    }
    return startLabel + content + endLabel
}

export function generateDTS(obj: Record<string, any>, typeName: string): string {
    const content: string[] = []
    for (const key1 in obj) {
        if (Object.prototype.hasOwnProperty.call(obj, key1)) {
            const value = obj[key1]
            const prefix = key1
            if (typeof value === 'object') {
                for (const key2 in value) {
                    if (Object.prototype.hasOwnProperty.call(value, key2)) {
                        content.push(`'${prefix}.${key2}':string`)
                    }
                }
            } else {
                content.push(`'${prefix}':string`)
            }
        }
    }
    return `declare global {\nexport type ${typeName} = {\n${content.join('\n')}\n}\n}`
}
